import request from '@/utils/request'
import { getAccessToken,getRefreshToken } from '@/utils/auth'

// 用户登录
export function login(username, password) {
    const data = {
        username,
        password
    }
    return request({
        url: '/user/login',
        method: 'post',
        data: data
    })
}


// 获取用户信息
export function getInfo() {
    return request({
        url: '/user/getInfo',
        method: 'get'
    })
}

// 退出方法
export function logout() {
    const data = {
        accessToken: getAccessToken(),
        refreshToken: getRefreshToken()
    }
    console.log(data);
    return request({
        url: '/user/logout',
        method: 'post',
        data: data
    })
}


// 刷新访问令牌
export function refreshToken() {
    const data = {
        refreshToken: getRefreshToken()
    }
    return request({
        url: '/user/refresh-token',
        method: 'post',
        data: data
    })
}

